<template>
  <!-- 借还记录 -->
  <div id="app" class="SkCirculateModel">
    <j-modal
      :title="title"
      :width="width"
      :visible="visible"
      switchFullscreen
      :okButtonProps="{ class: { 'jee-hidden': disableSubmit } }"
      @cancel="handleCancel"
    >
      <a-table
        ref="table"
        size="middle"
        :scroll="{ x: true }"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"
        @change="handleTableChange"
      >
        <span slot="action" slot-scope="text, record">
          <a-space>
            <!-- <a @click="handleEdit2(record)" v-has="'management:sk_tool_manager:edit'">编辑</a> -->
            <a @click="handleRecord(record)">归还记录</a>
            <a @click="handleReturn(record)" :disabled="record.unReturnNum == 0">归还</a>

            <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
              <a>删除</a>
            </a-popconfirm>
            <!-- <a-dropdown>
              <a class="ant-dropdown-link">更多 <a-icon type="down"/></a>
              <a-menu slot="overlay">
                <a-menu-item>
                  <a @click="handleDetail(record)">详情</a>
                </a-menu-item>
                <a-menu-item v-has="'management:sk_tool_manager:delete'">
                </a-menu-item>
              </a-menu>
            </a-dropdown> -->
          </a-space>
        </span>
      </a-table>
      <span slot="footer">
        <a-button @click="handleCancel">关闭</a-button>
      </span>
    </j-modal>
    <!-- <sk-tool-lend-form ref="ToolLendForm" @ok="modalFormOk"></sk-tool-lend-form> -->
    <sk-tool-record ref="SkToolRecord"  @ok="modalFormOk"></sk-tool-record>
  </div>
</template>
<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import {filterDictTextByCache} from '@/components/dict/JDictSelectUtil'
import SkToolLendForm from "./SkToolLendForm";
import SkToolRecord from "./SkToolRecord";
export default {
  name: 'SkCirculateModel',
  mixins:[JeecgListMixin],
  components:{
    SkToolLendForm,
    SkToolRecord
  },
  data() {
    return {
      title: '借还记录',
      width: 1200,
      visible: false,
      disableSubmit: false,
      // 表头
      columns: [
        {
          title: '借出数量',
          align: 'center',
          dataIndex: 'lendNum'
        },

        {
          title: '借出人',
          align: 'center',
          dataIndex: 'lendUser'
        },
        {
          title: '借出时间',
          align: 'center',
          dataIndex: 'lendTime'
        },
        {
          title: '计划归还时间',
          align: 'center',
          dataIndex: 'returnPlanTime'
        },
        {
          title: '实际归还时间',
          align: 'center',
          dataIndex: 'returnRealTime'
        },
        {
          title: '已归还数量',
          align: 'center',
          dataIndex: 'returnNum'
        },
        {
          title: '未归还数量',
          align: 'center',
          dataIndex: 'unReturnNum',
        },
        {
          title: '状态',
          align: 'center',
          dataIndex: 'status',
          customRender:function (t,r,index) {
            if (t == 0) {
              return "未归还"
            }
            if (t == 1) {
              return "部分归还"
            }
            if (t == 2) {
              return "已归还"
            }
          }
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          fixed: 'right',
          width: 147,
          scopedSlots: { customRender: 'action' }
        }
      ],
      url: {
        list: "/management/skToolLendRecord/list",
        delete: "/management/skToolLendRecord/delete",
      },
      queryParam:{id:''}
    }
  },

  filters: {},

  computed: {},

  created() {},

  activated() {},

  mounted() {},

  methods: {
    handleEdit2(record){
      this.$refs.ToolLendForm.edit(record,false);
    },
    init(record) {
      console.log(record);
      this.queryParam.toolId = record.id;
      this.loadData();
      this.visible = true
      
    },
    close() {
      // this.$emit('close')
      console.log('ssssssssss');
      this.$emit('ok')
      this.visible = false
    },
    handleOk() {
      this.close()
    },
    submitCallback() {
      this.$emit('ok')
      this.visible = false
    },
    handleCancel() {
      this.close()
    },
    // 归还记录
    handleRecord(record){
      this.$refs.SkToolRecord.init(record,true);
    },
    // 归还
    handleReturn(record){
      this.$refs.SkToolRecord.init(record,false);
    }
  }
}
</script>
<style scoped>
/* @import url(); 引入css类 */
</style>
